﻿using BLL.Interfaces;
using DAL;
using POCOS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;

namespace GUI.Controllers
{
    public class RepositoryBasedController : Controller
    {
        //
        // GET: /RepositoryBased/

         private AuteurContext db = new AuteurContext();
        private IArticlesServices _articleServices;
        public  RepositoryBasedController(IArticlesServices articleServices)
        {
            this._articleServices = articleServices;
        }



       // public JsonResult ArticleList(string title ,int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
       // {
       //     try
       //     {
       //         Thread.Sleep(200);
       //int articlcount  = _articleServices.GetArticleCount();
       // var articles = _articleServices.GetArticles(jtStartIndex, jtPageSize, jtSorting);
       // return Json(new { Result = "OK", Records = articles, TotalRecordCount = articlcount });
       //     }
       //     catch (Exception ex)
       //     {
       //         return Json(new { Result = "ERROR", Message = ex.Message });
       //     }
       // }

       //    [HttpPost]
       //    public JsonResult GetArticlesByFilter(DateTime date, int auteurid, int startIndex, int count, string sorting)
       //    {
       //        try
       //        {
       //            var studentCount = _articleServices.GetArticleCountByFilter(date, auteurid);
       //            var students = _articleServices.GetArticlesByFilter(date, auteurid, startIndex, count, sorting);
       //            return Json(new { Result = "OK", Records = students, TotalRecordCount = studentCount });
       //        }
       //        catch (Exception ex)
       //        {
       //            return Json(new { Result = "ERROR", Message = ex.Message });
       //        }


       //    }

       //    [HttpPost]
       //    public JsonResult CreateArticle(Article article)
       //    {
       //        try
       //        {
       //            if (!ModelState.IsValid)
       //            {
       //                return Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." });
       //            }

       //          _articleServices.CreateArticle(article);
       //          return Json(new { Result = "OK", Record = article });
       //        }
       //        catch (Exception ex)
       //        {
       //            return Json(new { Result = "ERROR", Message = ex.Message });
       //        }
       //    }





    }
}
